package com.io.example.demoparent.ES.es;


import com.io.example.demoparent.ES.util.ESUtil;
import org.elasticsearch.action.update.UpdateRequest;
import org.elasticsearch.action.update.UpdateResponse;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.common.xcontent.XContentType;

import java.io.IOException;

/*
     修改文档信息
 */
public class ES_Index_Update {

    public static void main(String[] args) throws IOException {
        RestHighLevelClient client = ESUtil.esRestClient( );

        UpdateRequest updateRequest = new UpdateRequest( );
        updateRequest.index("user")
                .id("1001")
                .doc( XContentType.JSON,"userName","李四551" );

        UpdateResponse updateResponse = client.update(updateRequest, RequestOptions.DEFAULT);

        System.out.println("result = " +    updateResponse.getResult( ));
        client.close();
    }
}
